package com.flynn.rock.system.service.impl;

import com.flynn.rock.system.convert.AbstractRoleConvert;
import com.flynn.rock.system.entity.SysRoleEntity;
import com.flynn.rock.system.model.vo.RoleListVo;
import com.flynn.rock.system.repository.SysRoleRepository;
import com.flynn.rock.system.service.SysRoleService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

@Service
public class SysRoleServiceImpl implements SysRoleService {

    @Resource
    private SysRoleRepository sysRoleRepository;


    @Override
    public List<RoleListVo> getRoleList() {
        List<SysRoleEntity> roleEntities = sysRoleRepository.findAll();
        return roleEntities.stream().map(AbstractRoleConvert.INSTANCE::toRoleListVo).collect(Collectors.toList());
    }
}
